package com.example.gdzd_demo.file.easyexcel;

import cn.hutool.core.util.ZipUtil;
import com.alibaba.excel.EasyExcel;
import com.example.gdzd_demo.model.Student;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@SpringBootTest
public class testWriteExcel {

    @Test
    public void test() {

        String fileName = "F:\\gdzd_file\\test.xlsx";
        String zipPath = "F:\\gdzd_file\\test.zip";
        String sheetName = "ѧ��";
        List<List<String>> head = Arrays.asList(Arrays.asList("����", "����"));

        List<Student> students = new ArrayList<>();
        students.add(new Student("Alice",20));
        students.add(new Student("Bob",22));
        students.add(new Student("Charlie",19));
        try {
            EasyExcel.write(fileName, Student.class).sheet(sheetName).doWrite(students);
        } catch (Exception e) {
            e.printStackTrace();
        }

        ZipUtil.zip(fileName, zipPath); // ѹ���ļ�
    }
}
